﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prob_Distributions_ClassLibrary
{
    class DistribucionExponencialNegativa : IDistribucion
    {
        private double promedio;
        private RandomNumber rnd;
        private double menor;
        private double mayor=0;
        public DistribucionExponencialNegativa(double promedio,RandomNumber rnd)
        {
            this.promedio = promedio;
            this.rnd = rnd;
        }
        public List<double> getNRandoms(int cant)
        {
            List<double> lstRandoms=new List<double>();
            List<double> randoms = rnd.getNRandoms(cant);
            if (randoms.Count > 0)
            {
                menor = randoms[0];
                mayor = 0;
            }

            for (int i = 0; i < randoms.Count; i++)
            {
                lstRandoms.Add((double)this.promedio * (-1) * Math.Log(1 - randoms[i]));
                if (lstRandoms[i] > mayor)
                    mayor = lstRandoms[i];
                if (lstRandoms[i] < menor)
                    menor = lstRandoms[i];
            }
            return lstRandoms;
        }
        public decimal getMayor()
        {
            return (decimal) mayor;
        }
        public decimal getMenor()
        {
            return (decimal) menor;
        }
        public decimal getIntervalo(int intervalos)
        {
            return (decimal)(mayor - menor) / intervalos;
        }
        public double getLimiteSuperior()
        {
            return mayor;
        }
        public double getLimiteInferior()
        {
            return 0;
        }
    }
}
